package com.hy.web;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.hy.domain.Gift;
import com.hy.domain.MeetingGift;

@Controller
public class HylpController {

	@RequestMapping("hylp")
	public String hylp(Model model) {
		List<Gift> gifts = Gift.findAllGifts();
		List<MeetingGift> meetingGifts = MeetingGift.findMeetingGiftEntries(0, 1);
		if(meetingGifts != null && meetingGifts.size() > 0) {
			model.addAttribute("meetingGift", meetingGifts.get(0));
		}
		model.addAttribute("gifts", gifts);
		return "hylp";
	}
	
	@RequestMapping("hylp_xq")
	public String hylpXq(Model model, @RequestParam long id) {
		/*
		Gift gift = Gift.findGift(id);
		if(gift == null){
			return "redirect:404";
		}
		model.addAttribute("gift", gift);
		model.addAttribute("up", gift.getUp());
		model.addAttribute("next", gift.getNext());
		return "hylp_xq";
		*/
		return "redirect:/hylp/view/" + id + ".html";
	}
	
}
